<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        include_once ('../includes/utilidades.php');
        session_start();

        //print_r($_REQUEST);
        //print "____>" . strlen($_REQUEST['login']);  
                
        if ((isset($_REQUEST['login']))&&(strlen($_REQUEST['login'])>0)){
            $rolbase='club';
            
            crearUsuario($_REQUEST,$rolbase);
            
        }
            
            
        
        
        
        $sql = "select * from usuario usu,rol_usuario rol where rol.idusuario=usu.id order by idusuario";
        $usuario = select2($sql);
        print "<table border=1>";
        print "<tr><th>login</th>" .
                "<th>nombre</th>" .
                "<th>apellidos</th>" .
                "<th>email</th>" .
                "<th>roles</th>" .
                "</tr>";
                
        
        $usuant = "";
        foreach ($usuario as $us) {
            if ($usuant != $us['idusuario']) {
                print "<tr>";
                print "<td>" . "<a href=editarUsuario.php?id=" .$us['idusuario'] . ">". $us['login'] . "</a></td>";
                print "<td>" . $us['nombre'] . "</td>";
                print "<td>" . $us['apellidos'] . "</td>";
                print "<td>" . $us['email'] . "</td>";
                print "<td>";
                $usuant=$us['idusuario'];
            } 
            print "<br>" . $us['rol'];;
            if ($usuant != $us['idusuario']) {
                print "</td></tr>";
            }                        
        }
        print "</table>";

        
        print "<h3>Crear nuevo usuario</h3>";
        print "<form name=altaUsuario method=post action=usuarios.php>";        
        print "<table>";
        print "<tr><td>Login:</td><td><input type=text name=login value=''></td></tr>";
        print "<tr><td>Password:</td><td><input type=password name=password value=''></td></tr>";
        print "<tr><td>Nombre:</td><td><input type=nombre name=nombre value=''></td></tr>";
        print "<tr><td>Apellidos:</td><td><input type=apellidos name=apellidos value=''></td></tr>";
        print "<tr><td>email:</td><td><input type=email name=email value=''></td></tr>";
        print "<tr><td></td><td><input type=submit value='Crear'></td></tr>";
        print "</table>";
        print "</form>";
        
        //print_r($_SESSION);
        //$actual = $_SERVER['REQUEST_SCHEME'] . "://" . $_SERVER['SERVER_NAME'] . "/atletismo/index.php";
        //header("location: " . $actual); // Redirecting To Other Page
        ?>
    </body>
</html>
